package com.example.worktest;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
@SpringBootApplication
@RestController
@RequestMapping("/api")
public class PersonalInfoApplication {
    public static void main(String[] args) {
        SpringApplication.run(PersonalInfoApplication.class, args);
    }
    @PostMapping("/submit")
    public Map<String, Object> submitForm(HttpServletRequest request) {
        Map<String, Object> result = new HashMap<>();
        try {
            Map<String, String> formData = new HashMap<>();
            request.getParameterMap().forEach((key, value) -> {
                formData.put(key, value[0]);
            });
            System.out.println("收到表单数据: " + formData);
            result.put("success", true);
            result.put("message", "注册成功");
        } catch (Exception e) {
            result.put("success", false);
            result.put("message", "注册失败: " + e.getMessage());
        }
        return result;
    }
}